this.BX=this.BX||{};this.BX.Landing=this.BX.Landing||{};this.BX.Landing.UI=this.BX.Landing.UI||{};(function(e,r,n,s,i){"use strict";var t=function(e){babelHelpers.inherits(n,e);function n(e){var r;babelHelpers.classCallCheck(this,n);r=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(n).call(this,e));r.type=e.type;r.forms=e.forms;r.code=e.code;r.onSourceChangeHandler=e.onSourceChange;r.dynamicParams=e.dynamicParams;r.settingFieldsSelectors=["source"];r.addField(r.createSourceField());return r}babelHelpers.createClass(n,[{key:"createSourceField",value:function e(){var s=this;var t="";if(r.Type.isPlainObject(this.dynamicParams)&&r.Type.isPlainObject(this.dynamicParams.wrapper)&&r.Type.isPlainObject(this.dynamicParams.wrapper.settings)&&r.Type.isString(this.dynamicParams.wrapper.settings.source)){t=this.dynamicParams.wrapper.settings.source}var a=n.getSourceById(t);if(!a){var c=n.getSources();var o=babelHelpers.slicedToArray(c,1);a=o[0]}setTimeout(function(){s.onSourceChangeHandler(a)},0);return new BX.Landing.UI.Field.Dropdown({title:i.Loc.getMessage("LANDING_CARDS__SOURCE_FIELD_TITLE"),selector:"source",content:t,items:n.getSourceFieldItems(),onValueChange:function e(r){s.onSourceChangeHandler(n.getSourceById(r.getValue()))}})}},{key:"serialize",value:function e(){return this.fields.reduce(function(e,s){var i=s.getValue();if(s.selector==="source"){e.source=i;e.settings[s.selector]=i}else if(i==="@hide"||r.Type.isPlainObject(i)&&i.id==="@hide"){e.references[s.selector]="@hide";if(r.Dom.hasClass(s.layout,"landing-ui-field-dynamic-dropdown")){e.stubs[s.selector]=""}else if(r.Dom.hasClass(s.layout,"landing-ui-field-dynamic-image")){e.stubs[s.selector]={id:-1,src:"",alt:""}}}else if(n.isReference(i)){e.references[s.selector]={id:i}}else if(r.Type.isPlainObject(i)&&r.Type.isString(i.id)){e.references[s.selector]=i}else{e.stubs[s.selector]=i}return e},{settings:{},references:{},stubs:{}})}}],[{key:"getSources",value:function e(){return s.Env.getInstance().getOptions().sources}},{key:"getSourceById",value:function e(r){return n.getSources().find(function(e){return String(e.id)===String(r)})}},{key:"getSourceFieldItems",value:function e(){return n.getSources().map(function(e){return{name:e.name,value:e.id}})}},{key:"isReference",value:function e(s){var i=n.getSources();if(r.Type.isArray(i)){return i.some(function(e){if(r.Type.isArray(e.references)){return e.references.some(function(e){return e.id===s})}return false})}return false}}]);return n}(n.BaseForm);e.DynamicBlockForm=t})(this.BX.Landing.UI.Form=this.BX.Landing.UI.Form||{},BX,BX.Landing.UI.Form,BX.Landing,BX.Landing);
//# sourceMappingURL=dynamicblockform.bundle.map.js